/**
 * 
 */
package com.yullage.ann;

import java.util.ArrayList;
import java.util.List;

import com.yullage.ann.network.som.SomNetwork;
import com.yullage.ann.network.som.SomParameters;

/**
 * @author Yu-chun Huang
 * 
 */
public class BootSom {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		hw2();
		// test();
	}

	private static void hw2() {
		SomParameters params = new SomParameters();
		List<Integer> structure = new ArrayList<Integer>();
		structure.add(2);
		structure.add(5);
		structure.add(5);
		structure.add(5);
		structure.add(5);
		structure.add(5);
		params.setNetworkStructure(structure);

		params.setTrainingDataFileName("dataset/hw2pt.dat");
		params.setTrainingSimilarityFileName("dataset/hw2class.dat");

		params.setMaxEpochsPerLayer(5000);

		params.setAttractionForce(0.01);
		params.setRepulsionForce(0.1);

		SomNetwork neuralNetwork = new SomNetwork(params);
		neuralNetwork.initialize();
		neuralNetwork.train();
	}

	private static void test() {
		SomParameters params = new SomParameters();
		List<Integer> structure = new ArrayList<Integer>();
		structure.add(2);
		structure.add(3);
		structure.add(3);
		structure.add(1);

		params.setNetworkStructure(structure);

		params.setTrainingDataFileName("dataset/test_pt.dat");
		params.setTrainingSimilarityFileName("dataset/test_class.dat");

		params.setMaxEpochsPerLayer(5000);

		params.setAttractionForce(0.01);
		params.setRepulsionForce(0.1);

		SomNetwork neuralNetwork = new SomNetwork(params);
		neuralNetwork.initialize();
		neuralNetwork.train();

		List<Double> input;
		input = new ArrayList<Double>();
		input.add(1.0);
		input.add(1.0);
		System.out.println(neuralNetwork.getOutputVector(input).toString());

		input = new ArrayList<Double>();
		input.add(-1.0);
		input.add(1.0);
		System.out.println(neuralNetwork.getOutputVector(input).toString());

		input = new ArrayList<Double>();
		input.add(-1.0);
		input.add(-1.0);
		System.out.println(neuralNetwork.getOutputVector(input).toString());

		input = new ArrayList<Double>();
		input.add(1.0);
		input.add(-1.0);
		System.out.println(neuralNetwork.getOutputVector(input).toString());
	}

}
